<?php

!defined('IN_APP') && exit('Access Denied');

class usereventmodel extends modelbase {

      function get_one($eventid,$uid) {
		$userevent = $this->collection->findOne(array("eventid" => $eventid,"uid" => $uid));
		return $userevent;
    }

    /* 添加用户和活动关系 */
    function add($eventid,$uid,$username){
  		$userevent['eventid'] = $eventid;
  		$userevent['uid'] = $uid;
  		$userevent['username'] = $username;	
		$userevent['dateline'] = $this->base->time;
       	$this->collection->insert($userevent); 
        return 1;
    }

    function get_list( $query = array() ) {
        $usereventlist = array();
        $cursor = $this->collection->find($query); 
        foreach ($cursor as $userevent){
		    $userevent['format_dateline'] = tdate($userevent['dateline']);
            $usereventlist[] = $userevent;
        }
        return $usereventlist;
    }
    
	function get_event_ids( $query = array() ) {
        $eventids = array();
        $cursor = $this->collection->find($query,array('eventid' => true, 'uid' => true)); 
        foreach ($cursor as $userevent){
            $eventids[] = $userevent['eventid'];
        }
        return $eventids;
    }

}

